define(function(require){
    
    var $ = require('jquery');
    var _ = require('lib/underscore');
    var Backbone = require('lib/backbone');
    var tpl = require('lib/text!tpl/Product.html'); 
   
    return Backbone.View.extend({
        tagName: "li",
        template: _.template(tpl),
        events: {
            "click .destroy" : "clear"
        },

        initialize: function() {
            this.listenTo(this.model, 'change', this.render);
            this.listenTo(this.model, 'destroy', this.remove);
        },

        render: function() {
            this.$el.html(this.template(this.model.toJSON()));
            return this;
        },

        clear: function() {
            this.model.destroy();
        }
    });
    
});